Пример #1
0
        //Save Chenage
        public object SaveChenage(Activity[] countries)
        {
            try
            {
                foreach (Activity Activity in countries)
                {
                    if (Activity.State == StateEnumVM.Delete)
                    {
                        //Delete
                        var ObjectReturn = DeleteS.Activity(Activity);
                        if (ObjectReturn != null)
                        {
                            return(ObjectReturn);
                        }
                    }
                    else if (Activity.State == StateEnumVM.Update)
                    {
                        //Update
                        var ObjectReturn = UpdateS.Activity(Activity);
                        if (ObjectReturn != null)
                        {
                            return(ObjectReturn);
                        }
                    }
                    else if (Activity.State == StateEnumVM.Create)
                    {
                        //Create
                        var ObjectReturn = CreateS.Activity(Activity);
                        if (ObjectReturn != null)
                        {
                            return(ObjectReturn);
                        }
                    }
                }
                db.SaveChanges();

                return(new { RequestType = RequestTypeEnumVM.Success, Message = Token.Saved });
            }
            catch (Exception ex)
            {
                return(new { RequestType = RequestTypeEnumVM.Error, Message = Token.NotSaveChange });
            }
        }
Пример #2
0
        public object SavaChange(Category[] rentalCategories)
        {
            try
            {
                foreach (var rentalCategory in rentalCategories)
                {
                    if (rentalCategory.State == StateEnumVM.Delete)
                    {
                        object ObjectReturn = DeleteS.Category(rentalCategory);
                        if (ObjectReturn != null)
                        {
                            return(ObjectReturn);
                        }
                    }
                    else if (rentalCategory.State == StateEnumVM.Update)
                    {
                        object ObjectReturn = UpdateS.Category(rentalCategory);
                        if (ObjectReturn != null)
                        {
                            return(ObjectReturn);
                        }
                    }
                    else if (rentalCategory.State == StateEnumVM.Create)
                    {
                        object ObjectReturn = CreateS.Category(rentalCategory);
                        if (ObjectReturn != null)
                        {
                            return(ObjectReturn);
                        }
                    }
                }

                db.SaveChanges();
                this.RemoveFiles();

                return(new ResponseVM(RequestTypeEnumVM.Success, Token.SaveChange));
            }
            catch (Exception ex)
            {
                this.FilesRemove = new List <string>();
                return(new ResponseVM(RequestTypeEnumVM.Error, Token.NotSaveChange, ex.Message, ex));
            }
        }
Пример #3
0
        //Save Chenage
        public object SaveChenage(PagesRole[] paesRoles)
        {
            try
            {
                //Update
                var ObjectReturn = UpdateS.PagesRole(paesRoles);
                if (ObjectReturn != null)
                {
                    return(ObjectReturn);
                }

                db.SaveChanges();
                return(new { RequestType = RequestTypeEnumVM.Success, Message = Token.Saved });
            }
            catch (Exception ex)
            {
                return(new { RequestType = RequestTypeEnumVM.Error, Message = Token.NotSaveChange });
            }
        }
Пример #4
0
 //Save Chenage
 public object SaveChenage(RentalIndividualField[] rentalInputs)
 {
     try
     {
         foreach (var rentalInput in rentalInputs)
         {
             if (rentalInput.State == StateEnumVM.Delete)
             {
                 //Delete
                 var ObjectReturn = DeleteS.RentalIndividualField(rentalInput);
                 if (ObjectReturn != null)
                 {
                     return(ObjectReturn);
                 }
             }
             else if (rentalInput.State == StateEnumVM.Update)
             {
                 //Update
                 var ObjectReturn = UpdateS.RentalIndividualField(rentalInput);
                 if (ObjectReturn != null)
                 {
                     return(ObjectReturn);
                 }
             }
             else if (rentalInput.State == StateEnumVM.Create)
             {
                 //Create
                 var ObjectReturn = CreateS.RentalIndividualField(rentalInput);
                 if (ObjectReturn != null)
                 {
                     return(ObjectReturn);
                 }
             }
         }
         db.SaveChanges();
         return(new { RequestType = RequestTypeEnumVM.Success, Message = Token.Saved });
     }
     catch (Exception ex)
     {
         return(new { RequestType = RequestTypeEnumVM.Error, Message = Token.NotSaveChange });
     }
 }
Пример #5
0
 public object SaveChange(Material[] marks)
 {
     try
     {
         foreach (Material mark in marks)
         {
             if (mark.State == StateEnumVM.Delete)
             {
                 //Delete
                 var ObjectReturn = DeleteS.Material(mark);
                 if (ObjectReturn != null)
                 {
                     return(ObjectReturn);
                 }
             }
             else if (mark.State == StateEnumVM.Update)
             {
                 //Update
                 var ObjectReturn = UpdateS.Material(mark);
                 if (ObjectReturn != null)
                 {
                     return(ObjectReturn);
                 }
             }
             else if (mark.State == StateEnumVM.Create)
             {
                 //Create
                 var ObjectReturn = CreateS.Material(mark);
                 if (ObjectReturn != null)
                 {
                     return(ObjectReturn);
                 }
             }
         }
         db.SaveChanges();
         return(new { RequestType = RequestTypeEnumVM.Success, Message = Token.Saved });
     }
     catch (Exception ex)
     {
         return(new { RequestType = RequestTypeEnumVM.Error, Message = Token.NotSaveChange });
     }
 }
Пример #6
0
 //Save Chenage
 public object SaveChenage(Province[] provinces)
 {
     try
     {
         foreach (Province province in provinces)
         {
             if (province.State == StateEnumVM.Delete)
             {
                 //Delete
                 var ObjectReturn = DeleteS.Province(province);
                 if (ObjectReturn != null)
                 {
                     return(ObjectReturn);
                 }
             }
             else if (province.State == StateEnumVM.Update)
             {
                 //Update
                 var ObjectReturn = UpdateS.Province(province);
                 if (ObjectReturn != null)
                 {
                     return(ObjectReturn);
                 }
             }
             else if (province.State == StateEnumVM.Create)
             {
                 //Create
                 var ObjectReturn = CreateS.Province(province);
                 if (ObjectReturn != null)
                 {
                     return(ObjectReturn);
                 }
             }
         }
         db.SaveChanges();
         return(new { RequestType = RequestTypeEnumVM.Success, Message = Token.Saved });
     }
     catch (Exception ex)
     {
         return(new { RequestType = RequestTypeEnumVM.Error, Message = Token.NotSaveChange });
     }
 }
Пример #7
0
        /// <summary>
        /// تفضيل الاعلان
        /// </summary>
        /// <param name="adId"></param>
        /// <returns></returns>
        public object AdFavoriteToggle(int adId)
        {
            try
            {
                var Ad = db.Ads.Find(adId);

                object ObjectReturn = UpdateS.AdFavoriteToggle(Ad);
                if (ObjectReturn != null)
                {
                    return(ObjectReturn);
                }

                db.SaveChanges();
                return(new ResponseVM(RequestTypeEnumVM.Success, Token.Success));
            }
            catch (Exception ex)
            {
                return(new ResponseVM(RequestTypeEnumVM.Error, Token.SomeErrorInServer, ex));
            }
        }
Пример #8
0
 //Save Chenage
 public object SaveChenage(Menu[] menus)
 {
     try
     {
         foreach (Menu Menus in menus)
         {
             //Update
             var ObjectReturn = UpdateS.Menu(Menus);
             if (ObjectReturn != null)
             {
                 return(ObjectReturn);
             }
         }
         db.SaveChanges();
         return(new { RequestType = RequestTypeEnumVM.Success, Message = Token.Saved });
     }
     catch (Exception ex)
     {
         return(new { RequestType = RequestTypeEnumVM.Error, Message = Token.NotSaveChange });
     }
 }
Пример #9
0
        //Save Chenage
        public object SaveChenage(Address address, User user, UserRole[] userRoles, HttpPostedFileBase image, bool isUpdate)
        {
            try
            {
                var ObjectReturn = new object();
                if (isUpdate)
                {
                    ObjectReturn = UpdateS.User(address, user, image);
                }
                else
                {
                    ObjectReturn = CreateS.User(address, user, userRoles, image);
                }

                if (ObjectReturn != null)
                {
                    return(ObjectReturn);
                }

                db.SaveChanges();

                this.RemoveFiles();
                if (isUpdate)
                {
                    return new { RequestType = RequestTypeEnumVM.Success, Message = Token.Saved, User = GetUserDataForUpdate(user.Id) }
                }
                ;
                else
                {
                    return new { RequestType = RequestTypeEnumVM.Success, Message = Token.Saved, User = GetUserDataForUpdate(user.Id) }
                };
            }
            catch (Exception ex)
            {
                return(new { RequestType = RequestTypeEnumVM.Error, Message = Token.NotSaveChange });
            }
        }
Пример #10
0
        public object SaveChange(Address address, User user, HttpPostedFileBase image)
        {
            try
            {
                var ObjectReturn = UpdateS.User(address, user, image);
                if (ObjectReturn != null)
                {
                    return(ObjectReturn);
                }

                db.SaveChanges();

                var User = db.Users.Find(user.Id);
                CookieService.SetUserInCookie(User);
                LanguageService.SetCulture(User.LanguageType.Code);
                this.RemoveFiles();

                return(new { RequestType = RequestTypeEnumVM.Success, Message = Token.Saved });
            }
            catch (Exception ex)
            {
                return(new { RequestType = RequestTypeEnumVM.Error, Message = Token.NotSaveChange });
            }
        }