Exemplo n.º 1
0
        /// <summary>
        /// Save Change Calling From Api
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public object SaveChenage(UserVM user, bool isUpdateData, bool isUpdateCountry = false)
        {
            //PagesAllow PageAllow = PageService.GetPageAllow(PageEnumVM.Users);


            try
            {
                var ObjectReturn = CreateS.User(user);

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

                db.SaveChanges();

                return(new ResponseVM {
                    RequestType = RequestTypeEnumVM.Success, Message = isUpdateData || isUpdateData ? Token.Updated : Token.Created
                });
            }
            catch (Exception ex)
            {
                return(new ResponseVM {
                    RequestType = RequestTypeEnumVM.Error, Message = Token.NotSaveChange, DevMessage = ex.Message
                });
            }
        }
Exemplo n.º 2
0
        public object SaveChange(GroupsDisplayType[] adsGroupsItems)
        {
            try
            {
                foreach (var groupsFieldsDisplayType in adsGroupsItems)
                {
                    if (groupsFieldsDisplayType.State == StateEnumVM.Delete)
                    {
                        object ObjectReturn = DeleteS.GroupsDisplayType(groupsFieldsDisplayType);
                        if (ObjectReturn != null)
                        {
                            return(ObjectReturn);
                        }
                    }
                    else if (groupsFieldsDisplayType.State == StateEnumVM.Create)
                    {
                        object ObjectReturn = CreateS.GroupsDisplayType(groupsFieldsDisplayType);
                        if (ObjectReturn != null)
                        {
                            return(ObjectReturn);
                        }
                    }
                }

                db.SaveChanges();

                return(new ResponseVM(RequestTypeEnumVM.Success, Token.SaveChange));
            }
            catch (Exception ex)
            {
                return(new ResponseVM(RequestTypeEnumVM.Error, Token.NotSaveChange, ex.Message, ex));
            }
        }
Exemplo n.º 3
0
        public object SaveChenage(RentalGroupsItem[] adsGroupsItems)
        {
            try
            {
                foreach (var adsGroupsItem in adsGroupsItems)
                {
                    if (adsGroupsItem.State == StateEnumVM.Delete)
                    {
                        object ObjectReturn = DeleteS.RentalGroupsItem(adsGroupsItem);
                        if (ObjectReturn != null)
                        {
                            return(ObjectReturn);
                        }
                    }
                    else if (adsGroupsItem.State == StateEnumVM.Create)
                    {
                        object ObjectReturn = CreateS.RentalGroupsItem(adsGroupsItem);
                        if (ObjectReturn != null)
                        {
                            return(ObjectReturn);
                        }
                    }
                }

                db.SaveChanges();

                return(new ResponseVM(RequestTypeEnumVM.Success, Token.SaveChange));
            }
            catch (Exception ex)
            {
                return(new ResponseVM(RequestTypeEnumVM.Error, Token.NotSaveChange, ex.Message));
            }
        }
Exemplo n.º 4
0
        public object Create(CommentVM commentVM)
        {
            try
            {
                AdComment Comment      = new AdComment();
                object    ObjectReturn = CreateS.Comment(commentVM, Comment);
                if (ObjectReturn != null)
                {
                    return(ObjectReturn);
                }

                db.SaveChanges();
                db      = new TageerEntities();
                Comment = db.AdComments.Find(Comment.Id);
                return(new ResponseVM(RequestTypeEnumVM.Success, Token.Created, new CommentVM
                {
                    Id = Comment.Id,
                    AdId = Comment.FKAd_Id,
                    Comment = Comment.Comment,

                    UserImage = Comment.User.Image,
                    UserName = Comment.User.UserName
                }));
            }
            catch (Exception ex)
            {
                return(new ResponseVM(RequestTypeEnumVM.Error, Token.SomeErrorInServer, ex));
            }
        }
Exemplo n.º 5
0
        public object Create(AdCreateVM adCereateVM)
        {
            try
            {
                object ObjectReturn = CreateS.Ad(adCereateVM);
                if (ObjectReturn != null)
                {
                    return(ObjectReturn);
                }

                db.SaveChanges();
                return(new ResponseVM(RequestTypeEnumVM.Success, Token.Created));
            }
            catch (Exception ex)
            {
                return(new ResponseVM(RequestTypeEnumVM.Error, Token.SomeErrorInServer, ex));
            }
        }
Exemplo n.º 6
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 });
            }
        }
Exemplo n.º 7
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));
            }
        }
Exemplo n.º 8
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 });
     }
 }
Exemplo n.º 9
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 });
     }
 }
Exemplo n.º 10
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 });
     }
 }
Exemplo n.º 11
0
    public Question(string question_text, StackPanel stack, CreateS win, Theme t, int dif, Window okno, bool create = true)
    {
        StartWindow = okno;
        Dif         = dif;
        MW          = win;
        theme       = t;
        qPan        = stack;
        can         = new Canvas();
        if (create)
        {
            qPan.Children.Add(can);
        }
        can.Children.Add(close);
        can.Height = 100;
        can.Margin = new Thickness(10, 10, 10, 0);
        can.HorizontalAlignment = HorizontalAlignment.Stretch;
        can.Background          = Brushes.White;
        q_text    = question_text;
        text.Text = q_text;
        can.Children.Add(text);
        text.TextWrapping        = TextWrapping.Wrap;
        text.Margin              = new Thickness(5, 5, 20, 5);
        text.HorizontalAlignment = HorizontalAlignment.Stretch;
        text.VerticalAlignment   = VerticalAlignment.Stretch;
        close.BorderThickness    = new Thickness(0, 0, 0, 0);
        Canvas.SetRight(close, 0);
        Canvas.SetTop(close, 0);
        close.Background = Brushes.Transparent;
        close.Height     = 15;
        close.Width      = 15;
        close.Click     += DeliteQuestion;
        Image img = new Image();

        img.Source    = new BitmapImage(new Uri(@"/cross.png", UriKind.Relative));
        close.Content = img;
        can.MouseUp  += OpenText;
        can.MouseUp  += Redaktor;
        theme.Questions[Dif - 1].Add(this);
    }
        public object CreateTechnicalSupport(TechnicalSupportVM technicalSupport)
        {
            try
            {
                var ObjectReturn = CreateS.CreateTechnicalSupport(technicalSupport);

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

                db.SaveChanges();
                return(new ResponseVM {
                    RequestType = RequestTypeEnumVM.Success, Message = Token.Created
                });
            }
            catch (Exception ex)
            {
                return(new ResponseVM {
                    RequestType = RequestTypeEnumVM.Success, Message = Token.NotCreated, InnerException = ex.InnerException.Message
                });
            }
        }
Exemplo n.º 13
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 });
            }
        }
Exemplo n.º 14
0
        public object ActivePhoneNumber(string phoneNumber, int code)
        {
            int Status = db.ActiveAccountByPhoneAndCode(phoneNumber, code).First().Value;

            // Invalid Phone Number
            if (Status == 1)
            {
                return(new ResponseVM(RequestTypeEnumVM.Error, Token.InvalidPhoneNotFound));
            }
            //Invalid Active Code
            if (Status == 2)
            {
                return(new ResponseVM(RequestTypeEnumVM.Error, Token.InvalidCode));
            }
            //Already Activated
            if (Status == 3)
            {
                return(new ResponseVM(RequestTypeEnumVM.Info, Token.AlreadyActivated));
            }

            var User = db.Users.First(c => c.PhoneNumber == phoneNumber);


            LanguageService.SetCulture(User.LanguageType.Code);
            //Now Create Access Token
            AccessTokenVM AccessToken = CreateS.CreateToken(User, User.LanguageType.Code, false);

            //Activated
            return(new ResponseVM(RequestTypeEnumVM.Success, Token.Activated,
                                  new
            {
                IsActivePhone = true,
                UserInformation = new UsersData().GetUserIformation(User.Id),
                AccessToken
            }));
        }
Exemplo n.º 15
0
    public Theme(string imya, CreateS _cre, StackPanel s)
    {
        for (int i = 0; i < 10; i++)
        {
            Questions[i] = new List <Question>();
        }
        stac = s;
        MW   = _cre;

        theme_button = new Button()
        {
            Width           = 125,
            Height          = 80,
            Margin          = new Thickness(0, 5, 3, 0),
            BorderThickness = new Thickness(3, 3, 3, 3),
            Style           = (Style)Application.Current.Resources["ButtonStyle1"],
        };
        theme_button.Click += ThemeOpen;
        can = new Canvas()
        {
            Width  = 125,
            Height = 80,
        };
        NameBox = new TextBox()
        {
            Width                      = 117,
            Height                     = 60.5,
            Background                 = Brushes.Transparent,
            BorderThickness            = new Thickness(0),
            Margin                     = new Thickness(0, 13, 3, 0),
            HorizontalContentAlignment = HorizontalAlignment.Center,
            TextWrapping               = TextWrapping.Wrap,
            Text       = imya,
            IsReadOnly = true,
            Style      = (Style)Application.Current.Resources["Arrow_Cursor"],
        };
        NameBox.TextChanged             += NameChanges;
        NameBox.PreviewMouseDoubleClick += ChangeName;
        NameBox.LostFocus        += ChangeName_close2;
        NameBox.PreviewMouseDown += ThemeOpen;
        NameBox.KeyDown          += new KeyEventHandler(OnKeyDownHandler);


        Image img = new Image();

        img.Source = new BitmapImage(new Uri(@"/cross.png", UriKind.Relative));
        close      = new Button()
        {
            Content         = img,
            Width           = 15,
            Height          = 15,
            Margin          = new Thickness(104, 0, 0, 0),
            Background      = Brushes.Transparent,
            BorderThickness = new Thickness(0),
            BorderBrush     = Brushes.Transparent,
            Style           = (Style)Application.Current.Resources["ButtonStyle1"],
        };
        theme_button.Content = can;
        can.Children.Add(NameBox);
        can.Children.Add(close);
        stac.Children.Remove(MW.CreateTheme_button);
        stac.Children.Add(theme_button);
        stac.Children.Add(MW.CreateTheme_button);
        close.Click += del_theme;
    }