Example #1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name")] Auther auther)
        {
            if (id != auther.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(auther);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AutherExists(auther.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(auther));
        }
Example #2
0
        public void updateTest()
        {
            using (TransactionScope ts = new TransactionScope())//使整个代码块成为事务性代码

            {
                AuthDAO dao = new AuthDAO();
                Auther  a   = dao.Load(2);
                a.Auth_UserName = "******";
                dao.UpdateByPrimaryKey(a);
                //插入至上传表
                UploadManagementDAO uploadManagementDao1 = new UploadManagementDAO();
                uploadManagementDao1.Insert(new UploadManagement(a.Pk_Auth_Id, "bdl_auth", 1));

                Auther b = new Auther();
                b.Auth_UserName = "******";
                dao.Insert(b);
                //插入至上传表
                UploadManagementDAO uploadManagementDao = new UploadManagementDAO();
                uploadManagementDao.Insert(new UploadManagement(b.Pk_Auth_Id, "bdl_auth", 0));

                int p = 0;
                //int l = 8 / p;

                ts.Complete();
            }
        }
        public CreateBlogModel()
        {
            Auther a = new Auther()
            {
                Name     = "Vinay",
                LastName = "Singh",
                Email    = "*****@*****.**"
            };
            Auther b = new Auther()
            {
                Name     = "Vinay",
                LastName = "Singh",
                Email    = "*****@*****.**"
            };

            Auther c = new Auther()
            {
                Name     = "Vinay",
                LastName = "Singh",
                Email    = "*****@*****.**"
            };


            Authers.Add(a);
            Authers.Add(b);
            Authers.Add(c);
        }
Example #4
0
 public ActionResult Edit(Auther tr)
 {
     if (ModelState.IsValid == true)
     {
         if (tr.ImageFile != null)
         {
             string             fileName   = Path.GetFileNameWithoutExtension(tr.ImageFile.FileName);
             string             extention  = Path.GetExtension(tr.ImageFile.FileName);
             HttpPostedFileBase postedFile = tr.ImageFile;
             int length = postedFile.ContentLength;
             if (extention.ToLower() == ".jpg" || extention.ToLower() == ".jpeg" || extention.ToLower() == ".png")
             {
                 if (length <= 1000000)
                 {
                     fileName = fileName + extention;
                     tr.Image = "~/AppFiles/Images/" + fileName;
                     fileName = Path.Combine(Server.MapPath("~/AppFiles/Images/"), fileName);
                     tr.ImageFile.SaveAs(fileName);
                     db.Entry(tr).State = EntityState.Modified;
                     int a = db.SaveChanges();
                     if (a > 0)
                     {
                         ModelState.Clear();
                         return(RedirectToAction("Index", "Teacher"));
                     }
                     else
                     {
                         TempData["UpdateMessage"] = "<script>alert('Data not Updated')</script>";
                     }
                 }
                 else
                 {
                     TempData["SizeMessage"] = "<script>alert('Image Size Should Less Than 1 MB')</script>";
                 }
             }
             else
             {
                 TempData["ExtentionMessage"] = "<script>alert('Format Not Supported')</script>";
             }
         }
         else
         {
             tr.Image           = Session["Image"].ToString();
             db.Entry(tr).State = EntityState.Modified;
             int a = db.SaveChanges();
             if (a > 0)
             {
                 TempData["UpdateMessage"] = "<script>alert('Data Updated Successfully')</script>";
                 ModelState.Clear();
                 return(RedirectToAction("Index", "Teacher"));
             }
             else
             {
                 TempData["UpdateMessage"] = "<script>alert('Data not Updated')</script>";
             }
         }
     }
     return(View());
 }
Example #5
0
        private void Button_Click_5(object sender, RoutedEventArgs e)
        {
            AuthDAO authDAO     = new AuthDAO();
            Auther  auther      = authDAO.Login("123", "123");
            string  pingJsonStr = JsonTools.Obj2JSONStrNew(auther);

            MessageBox.Show(pingJsonStr);
        }
Example #6
0
        private void Button_Click_3(object sender, RoutedEventArgs e)
        {
            AuthDAO authDAO     = new AuthDAO();
            Auther  auther      = authDAO.GetByAuthLevel(Auther.AUTH_LEVEL_ADMIN);
            string  pingJsonStr = JsonTools.Obj2JSONStrNew(auther);

            MessageBox.Show(pingJsonStr);
        }
Example #7
0
        public ActionResult ConfirmDelete(int id = 0)
        {
            Auther auther = db.Authers.Find(id);

            db.Authers.Remove(auther);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Example #8
0
        public ActionResult Save(
            HttpPostedFile image,
            string Name,
            string Description,
            string Category,
            DateTime PublisDate,
            string ISBN,
            string Prices,
            string InStok,
            string Auther,
            string Pulisher
            )
        {
            BookValidation validation = new BookValidation();

            BookStore.Entites.Domain.Pulisher publisher = this.pulisherDataStore.Load(int.Parse(Pulisher));
            Auther   auther          = this.autherDataStore.Load(int.Parse(Auther));
            Category category        = this.categoryDataStore.Load(int.Parse(Category));
            string   imageuploadpath = "";

            if (image != null)
            {
                imageuploadpath = Server.MapPath(XmlConfigurator.GetSetting().PictureUploadFolder + Guid.NewGuid() + image.FileName);

                ///http://www.cs.tut.fi/~jkorpela/forms/file.html
                ///form üzerinde image yada farklı türde veri almak için bakılması önerilir.
                image.SaveAs(imageuploadpath);
            }

            Book book = new Book
            {
                Name        = Name,
                Description = Description,
                InStok      = (InStok == null ? false : true),
                ISBN        = ISBN,
                PublisDate  = PublisDate,
                Pulisher    = publisher,
                Auther      = auther,
                PicturePath = imageuploadpath,
            };

            /// veri katmanında(Data), bu şekilde (kategori ekleme) fonksiyonları hazırlanması
            /// kodlama esnasında kolaylıklar sağlamaktadır.
            book.AddToCategoriy(category); /// Book nesnesine dahil olmasını istediğimiz kategoriye ekliyoruz.

            //Kullanıcı istenildiği gibi nesne içeriğini doldurup / doldurmadığını
            //kontrol etmektedir.
            if (validation.Validate(book).IsValid)
            {
                this.bookdatastore.Insert(book);

                return(RedirectToAction("List"));
            }

            Session["Error"] = "Lütfen gerekli alanları doldurunuz...";

            return(RedirectToAction("Add"));
        }
Example #9
0
        /// <summary>
        /// find hash of book
        /// </summary>
        /// <returns>hash type of int</returns>
        public override int GetHashCode()
        {
            int hash = Name.GetHashCode();

            hash += Auther.GetHashCode();
            hash += Year.GetHashCode();
            hash += Publisher.GetHashCode();
            return(hash);
        }
Example #10
0
        public ActionResult Delete(int id = 0)
        {
            Auther auther = db.Authers.Find(id);

            if (auther == null)
            {
                return(HttpNotFound());
            }
            return(View(auther));
        }
Example #11
0
 public ActionResult Delete(int id)
 {
     using (MvcProject_Raihan01Entities db = new MvcProject_Raihan01Entities())
     {
         Auther emp = db.Authers.Where(x => x.AutherID == id).FirstOrDefault <Auther>();
         db.Authers.Remove(emp);
         db.SaveChanges();
         return(Json(new { success = true, message = "Deleted Successfully", JsonRequestBehavior.AllowGet }));
     }
 }
        public IActionResult Edit(Auther auther)
        {
            if (!ModelState.IsValid)
            {
                return(View(auther));
            }

            _authorRepository.Update(auther);
            return(RedirectToAction("Index"));
        }
Example #13
0
 public AutherDTO(Setter setter, Auther auther, string mac)
 {
     this.username          = auther.Auth_UserName;
     this.password          = auther.Auth_UserPass;
     this.organizationSort  = setter.Set_OrganizationSort;
     this.organizationName  = setter.Set_OrganizationName;
     this.organizationPhone = setter.Set_OrganizationPhone;
     this.offlineTime       = auther.Auth_OfflineTime.ToString().Replace("/", "-");
     this.clientId          = mac;
 }
 private void Page_Loaded(object sender, RoutedEventArgs e)
 {
     //加载图片
     if (LanguageUtils.IsChainese())
     {
         title_pic.Source = new BitmapImage(new Uri(@"\view\Images\bdl.PNG", UriKind.Relative));
         title_pic.Height = 198.4;
     }
     else
     {
         //TODO 英文图片
         title_pic.Source = new BitmapImage(new Uri(@"\view\Images\design.png", UriKind.Relative));
         title_pic.Height = 257;
     }
     try
     {
         if (SetterDAO.getSetter() != null)
         {
             if (SetterDAO.getSetter().Set_Unique_Id != "" && SetterDAO.getSetter().Set_Unique_Id != null)//判断是否激活
             {
                 Status.Content = LanguageUtils.GetCurrentLanuageStrByKey("SettingsView.Activated");
                 Color color = Color.FromArgb(255, 2, 200, 5);
                 Status.Foreground     = new SolidColorBrush(color);
                 BtnActivite.IsEnabled = false;
             }
         }
     }
     catch (InvalidOperationException ee)
     {
     }
     setterList = setterDao.ListAll();
     try { Pk_Set_Id = setterList[0].Pk_Set_Id; }
     catch (ArgumentOutOfRangeException ee)
     {
     }
     try
     {
         List <Auther> AutherList = new List <Auther>();
         auther = authDAO.GetAuther(auth_level);
         AutherList.Add(auther);
         ((this.FindName("DataGrid1")) as DataGrid).ItemsSource = AutherList;
     }
     catch (Exception ee) { }
     try
     {
         DeviceSetList = deviceSetDAO.ListAll();
         ((this.FindName("ComboBox_Device")) as ComboBox).ItemsSource = DeviceSetList;//系列
         int Dset_Id = (int)ComboBox_Device.SelectedValue;
         DeviceSortList = deviceSortDAO.GetDeviceSortBySet(Dset_Id);
         ((this.FindName("DataGrid2")) as DataGrid).ItemsSource = DeviceSortList;//类型
     }
     catch (Exception ee)
     {
     }
 }
Example #15
0
        public IHttpActionResult GetAuther(int id)
        {
            Auther auther = db.FindAutherById(id);

            if (auther == null)
            {
                return(NotFound());
            }

            return(Ok(auther));
        }
Example #16
0
        private void Name_LostFocus(object sender, RoutedEventArgs e)
        {
            //获取文本框的值
            string Name       = UserName.Text;
            Auther AutherTemp = authDAO.GetByName(Name);

            if (AutherTemp != null)
            {
                MessageBoxX.Info(LanguageUtils.ConvertLanguage("用户名已存在", "The username has already existed"));
            }
        }
Example #17
0
        public IHttpActionResult PostAuther(Auther auther)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.AddAuther(auther);

            return(CreatedAtRoute("DefaultApi", new { id = auther.Auth_Id }, auther));
        }
Example #18
0
 public ActionResult Delete(int id, Auther auther)
 {
     try
     {
         autherRepository.delete(id);
         return(RedirectToAction(nameof(Index)));
     }
     catch
     {
         return(View());
     }
 }
Example #19
0
        public async Task <IActionResult> Create([Bind("Id,Name")] Auther auther)
        {
            if (ModelState.IsValid)
            {
                auther.CreateAt = DateTime.Now;
                _context.Add(auther);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(auther));
        }
Example #20
0
 public ActionResult Create(Auther auther)
 {
     try
     {
         // TODO: Add insert logic here
         autherReposetory.Add(auther);
         return(RedirectToAction(nameof(Index)));
     }
     catch
     {
         return(View());
     }
 }
Example #21
0
        public IHttpActionResult DeleteAuther(int id)
        {
            Auther auther = db.FindAutherById(id);

            if (auther == null)
            {
                return(NotFound());
            }

            db.RemoveAuther(id);

            return(Ok(auther));
        }
Example #22
0
 public ActionResult Delete(int id, Auther auther)
 {
     try
     {
         // TODO: Add delete logic here
         autherReposetory.Delete(id);
         return(RedirectToAction(nameof(Index)));
     }
     catch
     {
         return(View());
     }
 }
 public ActionResult Edit(int id, Auther auther)
 {
     try
     {
         // TODO: Add update logic here
         autherrepository.update(id, auther);
         return(RedirectToAction(nameof(Index)));
     }
     catch
     {
         return(View());
     }
 }
Example #24
0
        /// <summary>
        /// FillCommitDetails
        /// </summary>
        /// <param name="changeRequest"></param>
        /// <returns></returns>
        public static CommitObject FillCommitDetails(ChangeRequest changeRequest)
        {
            try
            {
                var refUpdate = new Refupdate
                {
                    name        = changeRequest.SourceBranchName,
                    oldObjectId = changeRequest.Lastcomitid
                };

                var commit = new Commit
                {
                    comment = changeRequest.Comments
                };
                Auther auther = new Auther
                {
                    date = changeRequest.CommitDate,
                    name = changeRequest.AutherName
                };
                commit.auther = auther;
                Change[] changes = new Change[changeRequest.RequestDetails.Count()];
                int      i       = 0;
                foreach (var item in changeRequest.RequestDetails)
                {
                    changes[i] = new Change
                    {
                        changeType = item.ChangeType,//"add",
                        item       = new Item {
                            path = @"/" + item.FileDestinationPath + @"/" + item.FileName
                        },
                        newContent = new Newcontent {
                            content = item.FileContent, contentType = item.ContentType
                        }
                    };
                    i = i + 1;
                }
                commit.changes = changes;

                var payload = new CommitObject {
                    refUpdates = new Refupdate[] { refUpdate }, commits = new Commit[] { commit }
                };

                return(payload);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #25
0
        public IActionResult Get(int id)
        {
            //AutoMapperTest
            Auther auther = new Auther()
            {
                Id        = 0,
                FirstName = "Abanoub",
                LastName  = "Labeeb",
                NickName  = "Andrew"
            };

            AutherDto autherDto = _mapper.Map <AutherDto>(auther);

            return(StatusCode(StatusCodes.Status200OK, autherDto.LastName));
        }
Example #26
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Auther = await _context.Auther.FirstOrDefaultAsync(m => m.AuthorId == id);

            if (Auther == null)
            {
                return(NotFound());
            }
            return(Page());
        }
Example #27
0
        public IHttpActionResult PutAuther(int id, Auther auther)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != auther.Auth_Id)
            {
                return(BadRequest());
            }

            db.EditAuther(auther);


            return(StatusCode(HttpStatusCode.NoContent));
        }
Example #28
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Auther = await _context.Auther.FindAsync(id);

            if (Auther != null)
            {
                _context.Auther.Remove(Auther);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }
Example #29
0
 public ActionResult Create(Auther author)
 {
     if (ModelState.IsValid)
     {
         try
         {
             // TODO: Add insert logic here
             authorRepository.Add(author);
             return(RedirectToAction(nameof(Index)));
         }
         catch
         {
             return(View());
         }
     }
     ModelState.AddModelError("", "Fill all required fields");
     return(View());
 }
 //刷新页面
 private void FlushAuther()
 {
     try
     { //添加之后,flush界面
       //致空
         auther = null;
         //刷新界面
         Auther        AutherTemp = authDAO.GetAuther(auth_level);
         List <Auther> AutherList = new List <Auther>();
         AutherList.Add(AutherTemp);
         ((this.FindName("DataGrid1")) as DataGrid).ItemsSource = AutherList;
     }
     catch (Exception ee)
     {
         List <Auther> AutherList = null;
         ((this.FindName("DataGrid1")) as DataGrid).ItemsSource = AutherList;
     }
 }