1
Vote

Core service:AreaService implementation required.

description

We have a total of 16 core services which requires implementation.

Service scoped into this task:
  1. AreaService
1) Area Service will consist of the following interface members.
 //Checks the specified name for being unique within the namespace
 //of Client client. If the name is valid, a new Area will be
 //created, assigned to Client client and added to persistence
 //context.
Area Create(Client client, string name)


//Resolves an Area by its name and owning client.
Area GetByName(Client client, string name)


comments

Ra3aHa5nain wrote Jun 2, 2014 at 7:29 PM

Please note: Developers will need to create a Folder within Tests called Functional Tests, we should use MOQ in-order to create our fakes.

Thank you

Vonstay wrote Jun 14, 2014 at 12:09 PM

Has this task been assigned to anyone if not I can try and take this on.

Vonstay wrote Jun 14, 2014 at 1:29 PM

Am I on the right track with this?
class AreaService
    {
        //Checks the specified name for being unique within the namespace
        //of Client client. If the name is valid, a new Area will be
        //created, assigned to Client client and added to persistence
        //context.
        Area Create(Client client, string name)
        {

            bool isFound = client.Area.Any(item => item.Name.Equals(name, StringComparison.OrdinalIgnoreCase));
            if (isFound) return null;

            //Initialize a new Area with the given name
            Area area = new Area();
            area.Name = name;
            return area;
        }


        //Resolves an Area by its name and owning client.
        Area GetByName(Client client, string name)
        {
            var rst = (from n in client.Area where n.Name.Equals(name, StringComparison.OrdinalIgnoreCase) select n).First();
            return rst;
        }

    }

Vonstay wrote Jun 14, 2014 at 5:24 PM

Missing the following in the Area Create Function
 client.Area.Add(area); //Add area to client persistence