Exemplo n.º 1
0
 private void AddGetById()
 {
     Add(Tab(2), string.Format("public Task<{0}Contract> Get{0}ById(int id)", EntityName));
     Add(Tab(2), "{");
     Add(Tab(3), "return Task.Run(() =>");
     Add(Tab(3), "{");
     Add(Tab(4), string.Format("var {0} = {1}Service.Get{1}ById(id);", EntityName.LowerCaseFirstCharacter(), EntityName, EntityName));
     Add(Tab(4), string.Format("return {0}Contract.Create().MapToModelFromDomainModel({1});", EntityName, EntityName.LowerCaseFirstCharacter()));
     Add(Tab(3), "});");
     Add(Tab(2), "}", NewLine());
 }
Exemplo n.º 2
0
        private void AddAdd()
        {
            Add(Tab(2), string.Format("public Task<IServiceResponse<{0}, {0}Contract>> Add{0}({0}Contract {1}Contract)", EntityName, EntityName.LowerCaseFirstCharacter()));
            Add(Tab(2), "{");
            Add(Tab(3), string.Format("var {0}ToAdd = {0}Contract.MapToDomainModelFromModel({0}Contract);", EntityName.LowerCaseFirstCharacter()), NewLine());
            Add(Tab(3), "return Task.Run(() =>");
            Add(Tab(3), "{");

            if (!Settings.IsIncludeCrudEntity)
            {
                Add(Tab(4), string.Format("{0}ToAdd.SetStateAdded();", EntityName.LowerCaseFirstCharacter()));
            }

            Add(Tab(4), string.Format("var response = {0}Service.Add{0}({1}ToAdd);", EntityName, EntityName.LowerCaseFirstCharacter()));
            Add(Tab(4), string.Format("return Response(response.Entity, {0}Contract, response.ValidationState);", EntityName.LowerCaseFirstCharacter()));
            Add(Tab(3), "});");
            Add(Tab(2), "}", NewLine());
        }
        private void BuildMethods()
        {
            Add(Tab(2), "#region Methods");

            if (Settings.IsIncludeCrud)
            {
                Add(Tab(2), string.Format("Task<IEnumerable<{0}Contract>> Get{0}All();", EntityName), NewLine());
                Add(Tab(2), string.Format("Task<{0}Contract> Get{0}ById(int id);", EntityName), NewLine());
                Add(Tab(2), string.Format("Task<IServiceResponse<{0}, {0}Contract>> Add{0}({0}Contract {1}Contract);", EntityName, EntityName.LowerCaseFirstCharacter()), NewLine());
                Add(Tab(2), string.Format("Task<IServiceResponse<{0}, {0}Contract>> Update{0}({0}Contract {1}Contract);", EntityName, EntityName.LowerCaseFirstCharacter()), NewLine());
                Add(Tab(2), string.Format("Task Delete{0}(int id);", EntityName));
            }

            Add(false, Tab(2), "#endregion");
        }