Clear[fPcs,L]; 
L = π; 
fPcs[x_] := Piecewise[{{0,-L≤x<0},{Sin[x],0≤x<L}}]
Plot[fPcs[x],{x,-L,L},PlotStyle->{Red, Thick}]

If f[x] is defined on [-L, L], its Fourier Series is  a[0]/2 + series(a[n] Cos[n π x/L), {n,1,∞}) + series(b[n] Sin[n π x/L], {n,1,∞}) 
with  coefficients 	a[n] = 1/L (∫_(-L)^L)f(x) Cos[n π x/L]dx, n≥ 0 and         b[n] = 1/L (∫_(-L)^L)f(x) Sin[n π x/L]dx, n≥1.
Since Cos[0 π x/L] = 1, we calculate a[0] separately.

1/L (∫_(-L)^L)fPcs[x] \[DifferentialD]x

the integrands (except for 1/L) for the first several cosine coefficients

Table[Sin[x] Cos[n π x/L],{n,1,5}]

evaluate these like this...

(1/L)(∫_0^L){Cos[x] Sin[x],Cos[2 x] Sin[x],Cos[3 x] Sin[x],Cos[4 x] Sin[x],Cos[5 x] Sin[x]}\[DifferentialD]x

they are the coefficients of these functions

Table[Cos[n π x/L],{n,1,5}]

the dot product of coefficients and functions gives the first few cosine terms

(2/π)*(1/2)+{0,-(2/(3 π)),0,-(2/(15 π)),0}.{Cos[x],Cos[2 x],Cos[3 x],Cos[4 x],Cos[5 x]}

several of the integrands for the sine coefficients

Table[Sin[x] Sin[n π x/L]/L,{n,1,5}]

and their integrated values

(∫_0^L){(((Sin[x])^2)/π),((Sin[x] Sin[2 x])/π),((Sin[x] Sin[3 x])/π),((Sin[x] Sin[4 x])/π),((Sin[x] Sin[5 x])/π)}\[DifferentialD]x

the corresponding terms for the sine coefficients

Table[Sin[n π x/L],{n,1,5}]

the dot product gives us the first few sine terms

{(1/2),0,0,0,0}.{Sin[x],Sin[2 x],Sin[3 x],Sin[4 x],Sin[5 x]}

a partial Fourier sum

(2/π)*(1/2)+{0,-(2/(3 π)),0,-(2/(15 π)),0}.{Cos[x],Cos[2 x],Cos[3 x],Cos[4 x],Cos[5 x]} + {(1/2),0,0,0,0}.{Sin[x],Sin[2 x],Sin[3 x],Sin[4 x],Sin[5 x]}

combining the plot with the original function

Show[Plot[fPcs[x],{x,-L,L},PlotStyle->{Red, Thick}],
Plot[(1/π)-((2 Cos[2 x])/(3 π))-((2 Cos[4 x])/(15 π))+((Sin[x])/2),{x,-L,L},PlotStyle->{Blue, Thick}]]