예제 #1
0
        public Result <Employee> Save(Employee Entity)
        {
            var result = new Result <Employee>();

            try
            {
                var objtosave = _context.Employees.FirstOrDefault(u => u.EmployeeId == Entity.EmployeeId);
                if (objtosave == null)
                {
                    objtosave = new Employee();
                    _context.Employees.Add(Entity);
                }
                else
                {
                    objtosave = Entity;
                }

                if (!IsValid(objtosave, result))
                {
                    return(result);
                }

                _context.SaveChanges();
            }
            catch (Exception e)
            {
                result.HasError = true;
                result.Message  = e.Message;
            }

            return(result);
        }
예제 #2
0
        public Result <RequestForService> Save(RequestForService Entity)
        {
            var result = new Result <RequestForService>();

            try
            {
                var objtosave = _context.Requests.FirstOrDefault(u => u.RequestId == Entity.RequestId);
                if (objtosave == null)
                {
                    objtosave = new RequestForService();
                    _context.Requests.Add(Entity);
                }
                else
                {
                    objtosave = new RequestForService();
                    objtosave = Entity;
                }

                if (!IsValid(objtosave, result))
                {
                    return(result);
                }

                _context.SaveChanges();
            }
            catch (Exception e)
            {
                result.HasError = true;
                result.Message  = e.Message;
            }

            return(result);
        }
예제 #3
0
        public Result <Notification> Save(Notification Entity)
        {
            var result = new Result <Notification>();

            try
            {
                var objtosave = _context.Notifications.FirstOrDefault(u => u.NotificationId == Entity.NotificationId);
                if (objtosave == null)
                {
                    objtosave = new Notification();
                    _context.Notifications.Add(Entity);
                }
                else
                {
                    objtosave = Entity;
                }

                if (!IsValid(objtosave, result))
                {
                    return(result);
                }


                _context.SaveChanges();
            }
            catch (Exception e)
            {
                result.HasError = true;
                result.Message  = e.Message;
            }

            return(result);
        }
예제 #4
0
        public Result <AssignWorkShop> Save(AssignWorkShop Entity)
        {
            var result = new Result <AssignWorkShop>();

            try
            {
                var objtosave = _context.AssignWorkShops.FirstOrDefault(u => u.AssignWorkShopId == Entity.AssignWorkShopId);
                if (objtosave == null)
                {
                    objtosave = new AssignWorkShop();
                    _context.AssignWorkShops.Add(Entity);
                }
                else
                {
                    objtosave = Entity;
                }

                if (!IsValid(objtosave, result))
                {
                    return(result);
                }


                _context.SaveChanges();
            }
            catch (Exception e)
            {
                result.HasError = true;
                result.Message  = e.Message;
            }

            return(result);
        }
        public Result <Volunteer> Save(Volunteer Entity)
        {
            var result = new Result <Volunteer>();

            try
            {
                var objtosave = _context.Volunteers.FirstOrDefault(u => u.VolunteerId == Entity.VolunteerId);
                if (objtosave == null)
                {
                    objtosave = new Volunteer();
                    _context.Volunteers.Add(Entity);
                }

                if (!IsValid(objtosave, result))
                {
                    return(result);
                }

                _context.SaveChanges();
            }
            catch (Exception e)
            {
                result.HasError = true;
                result.Message  = e.Message;
            }

            return(result);
        }