예제 #1
0
        public async Task<ReturnModel<ClientModel>> Create (ClientModel ClientModel)
        {
            var result = new ReturnModel<ClientModel> { Status = true };
            using(var session = new UnitOfWork<FoodMenuEntities>())
            {
                var ClientRepository = session.GetRepository<IClientRepository>();

                var client = new Client();
                client.Id = ClientModel.Id;
                client.Name = ClientModel.Name;
                client.Email = ClientModel.Email;
                client.Phone = ClientModel.Phone;
                client.Nationalid = ClientModel.Nationalid;
                client.Sex = ClientModel.Sex;
                client.Height = ClientModel.Height;
                client.Weight = ClientModel.Weight;
                client.FatPercentage = ClientModel.FatPercentage;
                client.Goal = ClientModel.Goal;
                client.Pills = ClientModel.Pills;
                client.Supplement = ClientModel.Supplement;
                client.RedirectedBy = ClientModel.RedirectedBy;
                client.Price = ClientModel.Price;
                client.RMR = ClientModel.RMR;
                client.UserId = ClientModel.UserId;
                ClientRepository.Add(client);

                await session.SaveChangesAsync();

                ClientModel.Id = client.Id;
                result.Result = ClientModel;
                return result;
            }
        }
예제 #2
0
 public async Task<ReturnModel<bool>> Put (int id,ClientModel client)
 {
     client.Id = id;
     return await ClientBl.Update(client);
 }
예제 #3
0
 //[AllowAnonymous]
 public async Task<ReturnModel<ClientModel>> Post (ClientModel client)
 {
     client.Id = LogedInUser.Id;
     return await ClientBl.Create(client);
 }
예제 #4
0
        public async Task<ReturnModel<ClientModel>> GetByID (int ClientID)
        {
            ClientModel clientModel = new ClientModel();
            using(var session = new UnitOfWork<FoodMenuEntities>())
            {
                var ClientRepository = session.GetRepository<IClientRepository>();

                var client = await ClientRepository.GetByID(ClientID);

                clientModel.Id = client.Id;
                clientModel.Name = client.Name;
                clientModel.Email = client.Email;
                clientModel.Phone = client.Phone;
                clientModel.Nationalid = client.Nationalid;
                clientModel.Sex = client.Sex;
                clientModel.Height = client.Height;
                clientModel.Weight = client.Weight;
                clientModel.FatPercentage = client.FatPercentage;
                clientModel.Goal = client.Goal;
                clientModel.Pills = client.Pills;
                clientModel.Supplement = client.Supplement;
                clientModel.RedirectedBy = client.RedirectedBy;
                clientModel.Price = client.Price;
                clientModel.RMR = client.RMR;
                clientModel.UserId = client.UserId;
                clientModel.UserName = client.User.FirstName + " " + client.User.LastName;

                return new ReturnModel<ClientModel>
                {
                    Status = true,
                    Result = clientModel
                };
            };
        }