Beispiel #1
0
        public async Task <BaseResponseModel> Edit(AffectedFieldModel request)
        {
            BaseResponseModel response = new BaseResponseModel();

            if (request.Validate())
            {
                AffectedField affectedField = await Load(request.Id, response);

                if (affectedField != null)
                {
                    affectedField.Name        = request.Name;
                    affectedField.Description = request.Description;

                    await Database.SaveChangesAsync();

                    response.Message = "Affected field was successfully edited!";
                }
            }
            else
            {
                response.Success = false;
                response.Message = "Some of the required properties is not present!";
            }

            return(response);
        }
Beispiel #2
0
        public async Task <BaseResponseModelPost> Create(AffectedFieldModel request)
        {
            BaseResponseModelPost response = new BaseResponseModelPost();

            if (request.Validate())
            {
                AffectedField affectedField = new AffectedField
                {
                    Name        = request.Name,
                    Description = request.Description
                };

                await Database.AffectedField.AddAsync(affectedField);

                await Database.SaveChangesAsync();

                response.Id      = affectedField.Id;
                response.Message = "Affected field was successfully created!";
            }
            else
            {
                response.Success = false;
                response.Message = "Some of the required properties is not present!";
            }

            return(response);
        }