Пример #1
0
        public static StructureCreation Update(StructureCreation structureCreation)
        {
            try
            {
                using Repository <StructureCreation> repo = new Repository <StructureCreation>();
                repo.StructureCreation.Update(structureCreation);
                if (repo.SaveChanges() > 0)
                {
                    return(structureCreation);
                }

                return(null);
            }
            catch { throw; }
        }
        public IActionResult RegisterStructureCreation([FromBody] StructureCreation structureCreation)
        {
            if (structureCreation == null)
            {
                return(Ok(new APIResponse()
                {
                    status = APIStatus.FAIL.ToString(), response = $"{nameof(structureCreation)} cannot be null"
                }));
            }
            else
            {
                if (StructureCreationHelper.GetStructures(structureCreation.StructureCode) != null)
                {
                    return(Ok(new APIResponse()
                    {
                        status = APIStatus.FAIL.ToString(), response = "Code =" + structureCreation.StructureCode + " is already Exists,Please Use Another Code"
                    }));
                }

                try
                {
                    APIResponse apiResponse = null;
                    var         result      = StructureCreationHelper.Register(structureCreation);
                    if (result != null)
                    {
                        apiResponse = new APIResponse()
                        {
                            status = APIStatus.PASS.ToString(), response = result
                        };
                    }
                    else
                    {
                        apiResponse = new APIResponse()
                        {
                            status = APIStatus.FAIL.ToString(), response = "Registration Failed."
                        };
                    }

                    return(Ok(apiResponse));
                }
                catch (Exception ex)
                {
                    return(Ok(new APIResponse {
                        status = APIStatus.FAIL.ToString(), response = ex.Message
                    }));
                }
            }
        }
Пример #3
0
        public static StructureCreation Register(StructureCreation structureCreation)
        {
            try
            {
                using Repository <StructureCreation> repo = new Repository <StructureCreation>();
                structureCreation.Active = "Y";
                repo.StructureCreation.Add(structureCreation);
                if (repo.SaveChanges() > 0)
                {
                    return(structureCreation);
                }

                return(null);
            }
            catch { throw; }
        }
        public IActionResult UpdateStructureCreation([FromBody] StructureCreation structureCreation)
        {
            if (structureCreation == null)
            {
                return(Ok(new APIResponse()
                {
                    status = APIStatus.PASS.ToString(), response = $"{nameof(structureCreation)} cannot be null"
                }));
            }
            try
            {
                APIResponse apiResponse = null;

                StructureCreation result = StructureCreationHelper.Update(structureCreation);
                if (result != null)
                {
                    apiResponse = new APIResponse()
                    {
                        status = APIStatus.PASS.ToString(), response = result
                    };
                }
                else
                {
                    apiResponse = new APIResponse()
                    {
                        status = APIStatus.FAIL.ToString(), response = "Updation Failed."
                    };
                }
                return(Ok(apiResponse));
            }
            catch (Exception ex)
            {
                return(Ok(new APIResponse {
                    status = APIStatus.FAIL.ToString(), response = ex.Message
                }));
            }
        }