コード例 #1
0
 public UpdateAdmin GetAdminDetailById(int adminId)
 {
     try
     {
         UpdateAdmin updateAdmin    = new UpdateAdmin();
         var         getAdminDetail = (from o in dc.Admins where o.AdminId == adminId select o).FirstOrDefault();
         if (getAdminDetail != null)
         {
             UpdateAdminDetail upAdminDetail = new UpdateAdminDetail();
             upAdminDetail.Name  = getAdminDetail.Name;
             upAdminDetail.Email = getAdminDetail.Email;
             upAdminDetail.Phone = getAdminDetail.Phone;
             string dob  = Convert.ToString(getAdminDetail.DOB);
             string dd   = dob.Substring(0, 2);
             string mm   = dob.Substring(3, 2);
             string yyyy = dob.Substring(6, 4);
             upAdminDetail.DOB             = Convert.ToDateTime(dd + "-" + mm + "-" + yyyy);
             upAdminDetail.Gender          = getAdminDetail.Gender;
             upAdminDetail.IsEditAllow     = true;
             updateAdmin.updateAdminDetail = upAdminDetail;
         }
         else
         {
             updateAdmin.updateAdminDetail = null;
         }
         return(updateAdmin);
     }
     catch (Exception)
     {
         throw;
     }
 }
コード例 #2
0
 public bool UpdateAdminProfile(int adminId, UpdateAdminDetail updateAdminDetail, HttpPostedFileBase httpPostedFileBase)
 {
     try
     {
         bool IsUpdateSuccessfuly = false;
         dc.Configuration.ValidateOnSaveEnabled = false;
         var updateAdmin = (from o in dc.Admins where o.AdminId == adminId select o).FirstOrDefault();
         if (updateAdmin != null)
         {
             byte[] bytes;
             if (httpPostedFileBase != null)
             {
                 if (httpPostedFileBase.ContentLength > 0)
                 {
                     using (BinaryReader br = new BinaryReader(httpPostedFileBase.InputStream))
                     {
                         bytes = br.ReadBytes(httpPostedFileBase.ContentLength);
                     }
                     updateAdmin.Image     = bytes;
                     updateAdmin.ImageName = Path.GetFileName(httpPostedFileBase.FileName);
                     updateAdmin.ImageType = httpPostedFileBase.ContentType;
                 }
             }
             updateAdmin.Name            = updateAdminDetail.Name;
             updateAdmin.Email           = updateAdminDetail.Email;
             updateAdmin.Phone           = updateAdminDetail.Phone;
             updateAdmin.DOB             = Convert.ToDateTime(updateAdminDetail.DOB);
             updateAdmin.Gender          = updateAdminDetail.Gender;
             dc.Entry(updateAdmin).State = EntityState.Modified;
             Save();
             IsUpdateSuccessfuly = true;
         }
         return(IsUpdateSuccessfuly);
     }
     catch (Exception)
     {
         throw;
     }
 }
コード例 #3
0
 public bool UpdateAdminProfile(int adminId, UpdateAdminDetail updateAdminDetail, HttpPostedFileBase httpPostedFileBase)
 {
     return(adminDb.UpdateAdminProfile(adminId, updateAdminDetail, httpPostedFileBase));
 }