Exemple #1
0
        public ActionResult Create(AdminViewModel adminViewModel)
        {
            var usertest = User.Identity.Name;
            try
            {
                // TODO: Add insert logic here
                if (ModelState.IsValid)
                {
                    string UniqFileName = DateTime.Now.ToString("yyyymmddMMss") + adminViewModel.LogoFile.FileName;
                    Admin admin = new Admin()
                    {
                        AdminName = adminViewModel.AdminName,
                        Address = adminViewModel.Address,
                        //CreatedBy = adminViewModel.CreatedBy,
                        //CreatedDate = adminViewModel.CreatedDate,
                        Password = adminViewModel.Password,
                        DateOfEstablishment = adminViewModel.DateOfEstablishment,
                        Email = adminViewModel.Email,
                        FaxNumber = adminViewModel.FaxNumber,
                        LogoFile = UniqFileName,
                        //ModifiedDate = adminViewModel.ModifiedDate,
                        //ModifiedBy = adminViewModel.ModifiedBy,
                        OrganizationName = adminViewModel.OrganizationName,
                        PanNo = adminViewModel.PanNo,
                        PhoneNumbers = adminViewModel.PhoneNumbers,
                        POBoxNumber = adminViewModel.POBoxNumber,
                        VatNo = adminViewModel.VatNo,
                        Website = adminViewModel.Website,

                    };
                    string logoFilePath = Path.Combine(Server.MapPath("~/Uploads/AdminLogo"), UniqFileName);
                    adminViewModel.LogoFile.SaveAs(logoFilePath);
                    db.Admins.Add(admin);
                    db.SaveChanges();

                    IdentityManager im = new IdentityManager();
                    ApplicationUser user = new ApplicationUser() { UserName=admin.AdminName, };
                    im.CreateUser(user, admin.Password);
                    return RedirectToAction("Index");
                }

                return View(adminViewModel);

            }
            catch
            {
                return View();
            }
        }
Exemple #2
0
        public ActionResult Delete(int? id)
        {
            if (id == null)
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }
            Admin admin = db.Admins.Find(id);
            if (admin == null)
            {
                return HttpNotFound();
            }
            var adminViewModel = new AdminViewModel()
            {
                //AdminName = admin.AdminName,
                Address = admin.Address,
                //CreatedBy = admin.CreatedBy,
                //CreatedDate = admin.CreatedDate,
                //DateOfEstablishment = admin.DateOfEstablishment,
                //Email = admin.Email,
                //FaxNumber = admin.FaxNumber,
                //LogoFile = admin.LogoFile,
                //ModifiedDate = admin.ModifiedDate,
                //ModifiedBy = admin.ModifiedBy,
                OrganizationName = admin.OrganizationName,
                //PanNo = admin.PanNo,
                //PhoneNumber = admin.PhoneNumbers,
                //POBoxNumber = admin.POBoxNumber,
                //VatNo = admin.VatNo,
                Website = admin.Website,

            };

            return View(adminViewModel);
        }
Exemple #3
0
 public ActionResult Edit(int id, AdminViewModel adminViewModel)
 {
     try
     {
         // TODO: Add update logic here
         if (ModelState.IsValid)
         {
             Admin admin = new Admin()
             {
                 AdminId = id,
                 AdminName = adminViewModel.AdminName,
                 Address = adminViewModel.Address,
                 //CreatedBy = adminViewModel.CreatedBy,
                 //CreatedDate = adminViewModel.CreatedDate,
                 DateOfEstablishment = adminViewModel.DateOfEstablishment,
                 Email = adminViewModel.Email,
                 FaxNumber = adminViewModel.FaxNumber,
                 //LogoFile = adminViewModel.LogoFile,
                 //ModifiedDate = adminViewModel.ModifiedDate,
                 //ModifiedBy = adminViewModel.ModifiedBy,
                 OrganizationName = adminViewModel.OrganizationName,
                 PanNo = adminViewModel.PanNo,
                 PhoneNumbers = adminViewModel.PhoneNumbers,
                 POBoxNumber = adminViewModel.POBoxNumber,
                 VatNo = adminViewModel.VatNo,
                 Website = adminViewModel.Website,
             };
             db.Entry(admin).State = EntityState.Modified;
             db.SaveChanges();
             return RedirectToAction("Index");
         }
         return View(adminViewModel);
     }
     catch
     {
         return View();
     }
 }