Пример #1
0
        public async Task <IActionResult> Index()
        {
            ADTeam5User user = await _userManager.GetUserAsync(HttpContext.User);

            userid = user.WorkID;
            List <string> identity = userCheck.checkUserIdentityAsync(user);

            dept = identity[0];
            role = identity[1];

            Models.Department d1 = b.getDepartmentDetails(dept);
            int currentRepId     = d1.RepId;

            Models.User u1             = b.getUser(currentRepId);
            string      currentRepName = u1.Name;

            ViewData["CurrentRepName"] = currentRepName;

            List <User> u = new List <User>();

            Models.Department d = b.getDepartmentDetails(dept);
            int repid           = d.RepId;
            int headid          = d.HeadId;
            int coverheadid     = 0;

            if (d.CoveringHeadId != null)
            {
                coverheadid = (int)d.CoveringHeadId;
            }

            u = b.populateAssignDepartmentDropDownList(dept, repid, headid, coverheadid);

            ViewBag.listofitems = u;
            return(View());
        }
        public Models.Department Update(Models.Department department)
        {
            var dept = _context.Departments.Update(department);

            _context.SaveChanges();
            return(department);
        }
Пример #3
0
        public async Task <IActionResult> Index()
        {
            ADTeam5User user = await _userManager.GetUserAsync(HttpContext.User);

            userid = user.WorkID;
            List <string> identity = userCheck.checkUserIdentityAsync(user);

            dept = identity[0];
            role = identity[1];

            Models.Department d1 = b.getDepartmentDetails(dept);
            if (d1.CoveringHeadId != null)
            {
                edit = true;
                currentDeputyHeadId = (int)d1.CoveringHeadId;
                string name = b.getCurrentDeputyHeadName(currentDeputyHeadId);
                ViewData["CurrentDeputyHead"] = name;
                Models.DepartmentCoveringHeadRecord d2 = b.findCurrentDeputyHeadToEdit(currentDeputyHeadId);
                ViewData["CurrentDeputyHeadStartDate"] = d2.StartDate.ToShortDateString();
                ViewData["CurrentDeputyHeadEndDate"]   = d2.EndDate.ToShortDateString();
            }

            List <User> userList = new List <User>();

            Models.Department d = b.getDepartmentDetails(dept);
            int repid           = d.RepId;
            int headid          = d.HeadId;

            userList            = b.populateAssignDeputyDropDownList(dept, repid, headid);
            ViewBag.listofitems = userList;
            return(View());
        }
Пример #4
0
        //AssignDepartment
        public Models.Department getDepartmentDetails(string dept)
        {
            var q1 = context.Department.Where(x => x.DepartmentCode == dept).First();

            Models.Department d = q1;
            return(d);
        }
Пример #5
0
 public ActionResult DeleteDepartment(int a)
 {
     Models.Department d = new Models.Department();
     d.Dep_ID = a;
     d.delete();
     return(RedirectToAction("Department"));
 }
Пример #6
0
 //public void UpdateDepartment (Models.Department department)
 // After AutoMapper
 public void UpdateDepartment(int id, DepartmentDto department)
 {
     //var _department = DBContext.Departments.Single(x => x.Department_ID == id);
     Models.Department _department = iMapper.Map <DepartmentDto, Models.Department>(department);
     DBContext.Entry(_department).State = System.Data.Entity.EntityState.Modified;
     DBContext.SaveChanges();
 }
Пример #7
0
        public async Task <IActionResult> Create(Models.Department department)
        {
            _context.Departments.Add(department);
            await _context.SaveChangesAsync();

            return(Ok(department.Id));
        }
Пример #8
0
        public async Task <ActionResult <Department> > Add(
            [FromServices] IRepository <Models.Department, int> departmentRepository,
            [FromServices] IEntityScraper <Models.Department> departmentScraper,
            [FromBody] Uri uri)
        {
            var absoluteUrl      = uri.AbsoluteUri;
            var storedDepartment =
                departmentRepository.Find(department => department.Url == absoluteUrl).FirstOrDefault();

            if (storedDepartment == null)
            {
                var dateTime   = DateTime.Now;
                var department = new Models.Department
                {
                    Name      = "Unknown Department",
                    IsEnabled = true,
                    Url       = UriHelper.EnsureDepartmentUrl(absoluteUrl),
                    Added     = dateTime,
                    Updated   = dateTime,
                    Read      = dateTime
                };

                var transaction = PolicyHelper.WaitAndRetry().Execute(
                    () => departmentRepository.BeginTransaction(IsolationLevel.Serializable));
                departmentRepository.Add(department);
                await departmentRepository.SaveChangesAsync();

                await transaction.CommitAsync();

                return(department.ToDataTransferObject(true));
            }


            return(storedDepartment?.ToDataTransferObject());
        }
        void IMongoDepartmentDataSource.DeleteDepartment(Models.Department collection)
        {
            MongoCollection <Department> MCollection = database.GetCollection <Department>("Department");
            IMongoQuery query = Query.EQ("_id", collection._id);

            MCollection.Remove(query);
        }
        void IMongoDepartmentDataSource.CreateDepartment(Models.Department colleciton)
        {
            if (colleciton != null)
            {
                int Id = 0;
                if (Departments.Count() > 0)
                {
                    Id = Departments.Max(x => x.DepartmentId);
                }
                Id += 1;
                MongoCollection <Department> MCollection = database.GetCollection <Department>("Department");
                BsonDocument doc = new BsonDocument {
                    { "DepartmentId", Id },
                    { "DepartmentName", colleciton.DepartmentName },
                    { "CreatedDate", colleciton.CreatedDate }
                };

                IMongoQuery query  = Query.EQ("DepartmentName", colleciton.DepartmentName);
                var         exists = MCollection.Find(query);
                if (exists.ToList().Count == 0)
                {
                    MCollection.Insert(doc);
                }
            }
        }
Пример #11
0
        public ActionResult Create(Models.Department objModelDepartment)
        {
            try
            {
                // TODO: Add insert logic here
                int i = objDalDept.AddDept(objModelDepartment);
                if (i == 1)
                {
                    Models.AutoGenerate objModelAutoGenerate = new Models.AutoGenerate();
                    objModelAutoGenerate.TableName  = "dept";
                    objModelAutoGenerate.ColumnName = "dno";
                    objModelDepartment.Dno          = objServiceAuto.AutoGenerateId(objModelAutoGenerate);
                    ViewBag.message = "Department added";
                    return(View(objModelDepartment));
                }
                return(View());

                // return RedirectToAction("Index");
            }
            catch (Exception ex)
            {
                ViewBag.message = ex.Message;
                return(View());

                // return View();
            }
        }
Пример #12
0
 public Models.Department Post(Models.Department request)
 {
     if (request == null || !ModelState.IsValid)
     {
         throw new HttpException((int)HttpStatusCode.BadRequest, "Invalid Request");
     }
     return(departmentService.SaveUpdateDepartment(request.CreateFromm()).CreateFromm());
 }
 public string SaveDepartment(Models.Department department)
 {
     if (departmentGateway.SaveDepartment(department) > 0)
     {
         return("Department Saved Successfully.");
     }
     return("Department saving Failed.");
 }
Пример #14
0
        public ActionResult GenerateDisbursement(Models.Department department)
        {
            Dictionary <Item, int> departmentItemQuantity = reqService.GetDepartmentItemAndQuantity(department);

            ViewData["departmentItemAndQuantity"] = departmentItemQuantity;
            ViewBag.DepartmentID = new SelectList(reqService.GetDepartments(), "DepartmentID", "DepartmentName", department.DepartmentID);
            return(View("~/Views/Store/Clerk/GenerateDisbursement.cshtml", department));
        }
        void IMongoDepartmentDataSource.EditDepartment(Models.Department collection)
        {
            MongoCollection <Department> MCollection = database.GetCollection <Department>("Department");
            IMongoQuery  query  = Query.EQ("DepartmentId", collection.DepartmentId);
            IMongoUpdate update = MongoDB.Driver.Builders.Update.Set("DepartmentName", collection.DepartmentName).Set("CreatedDate", collection.CreatedDate);

            MCollection.Update(query, update);
        }
Пример #16
0
        public IHttpActionResult GetCollectionPointList(int id)
        {
            Models.Department      department       = db.Departments.SingleOrDefault(d => d.DepartmentID == id);
            List <CollectionPoint> collectionPoints = db.CollectionPoints.Where(c => c.CollectionPointID != department.CollectionPointID)
                                                      .ToList();

            return(Ok(collectionPoints));
        }
Пример #17
0
        public ActionResult UpdateDepartment(int a)
        {
            Department d = new Models.Department();

            d.Dep_ID = a;
            d.search();
            return(View(d));
        }
Пример #18
0
 public Boolean Delete(Models.Department request)
 {
     if (Request == null || !ModelState.IsValid)
     {
         throw new HttpException((int)HttpStatusCode.BadRequest, "Invalid Request");
     }
     departmentService.DeleteDepartment(request.DepartmentId);
     return(true);
 }
Пример #19
0
        public ActionResult AddEmployee()
        {
            Department dp = new Models.Department();

            ViewBag.depid = dp.all();
            Designation dsg = new Designation();

            ViewBag.ddddd = dsg.all();
            return(View());
        }
Пример #20
0
        public int DeleteDept(Models.Department objModelDept)
        {
            con.Open();
            string     query = "delete from dept where dno='" + objModelDept.Dno + "'";
            SqlCommand cmd   = new SqlCommand(query, con);
            int        i     = cmd.ExecuteNonQuery();

            con.Close();
            return(i);
        }
Пример #21
0
        public int AddDept(Models.Department objModelDept)
        {
            con.Open();
            string     query = "insert into dept (dno, dname) values ('" + objModelDept.Dno + "','" + objModelDept.Dname + "')";
            SqlCommand cmd   = new SqlCommand(query, con);
            int        i     = cmd.ExecuteNonQuery();

            con.Close();
            return(i);
        }
Пример #22
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            WebClient client = new WebClient();

            client.Headers["Content-type"] = "application/json";
            client.Encoding = Encoding.UTF8;
            if (Request.QueryString["status"] == "update")
            {
                ViewState["DeptID"] = Request.QueryString["dId"];

                string apiUrlUser = Utilities.BASE_URL + "/api/Departments";

                Committee.Models.Department department = new Models.Department()
                {
                    DeptId      = Convert.ToInt32(Request.QueryString["dId"]),
                    DeptName    = txtDeptName.Text,
                    DeptAddress = txtDeptAddress.Text,


                    // UserImage = "/" + ImgUpload?.PostedFile?.FileName
                };



                string inputJson = (new JavaScriptSerializer()).Serialize(department);
                try
                {
                    client.UploadString(apiUrlUser + "/PutDepartment?id=" + Convert.ToInt32(ViewState["DeptID"]), inputJson);
                }
                catch (Exception ex)
                {
                    Response.Write(ex.Message);
                }
                Response.Redirect("DepartmentMangement.aspx?id=redirectUpdate");
            }


            else if (Request.QueryString["status"] == "new")
            {
                string apiUrlMember = Utilities.BASE_URL + "/api/Departments";
                Committee.Models.Department dept = new Models.Department()
                {
                    DeptName    = txtDeptName.Text,
                    DeptAddress = txtDeptAddress.Text,
                };



                string inputJson = (new JavaScriptSerializer()).Serialize(dept);


                client.UploadString(apiUrlMember + "/PostDepartment", inputJson);
                Response.Redirect("DepartmentMangement.aspx?id=redirectSave");
            }
        }
Пример #23
0
        // Method declaration before AutoMapper
        // public Models.Department GetDepartmentByID(int departmentId)
        public DepartmentDto GetDepartmentByID(int departmentId)
        {
            // Code before AutoMapper
            //return DBContext.Departments.Find(departmentId);

            // Code after AutoMapper
            Models.Department deptSource      = DBContext.Departments.Find(departmentId);
            DepartmentDto     deptDestination = iMapper.Map <Models.Department, DepartmentDto>(deptSource);

            return(deptDestination);
        }
Пример #24
0
 public IHttpActionResult ChangeCollectionPoint(CustomDepartment customDepartment)
 {
     Models.Department dept = db.Departments.SingleOrDefault(d => d.DepartmentID == customDepartment.DepartmentID);
     if (dept == null)
     {
         return(NotFound());
     }
     dept.CollectionPointID = customDepartment.CollectionPoint.CollectionPointID;
     db.SaveChanges();
     return(Ok());
 }
Пример #25
0
        public async Task <IActionResult> Create([Bind("Id,Name")] Models.Department departments)
        {
            if (ModelState.IsValid)
            {
                _context.Add(departments);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(departments));
        }
Пример #26
0
        //TEST FOR ANDROID - Assign Department
        public int updateDepartment(string name, string dept)
        {
            var    q          = context.User.Where(x => x.Name == name).First();
            int    userid     = q.UserId;
            string department = q.DepartmentCode;
            var    q1         = context.Department.Where(x => x.DepartmentCode == dept).First();

            Models.Department d = q1;
            d.RepId = userid;
            context.SaveChanges();
            return(1);
        }
Пример #27
0
        public IActionResult Update([FromBody] Models.Department model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var entity = _repository.GetById(model.Id);

            Mapper.Map <Models.Department, Entities.Department>(model, entity);
            _repository.Update(entity);
            return(Ok());
        }
Пример #28
0
 public IHttpActionResult GetCollectionPoint(int id)
 {
     Models.Department department = db.Departments.SingleOrDefault(d => d.DepartmentID == id);
     if (department == null || department.CollectionPoint == null)
     {
         return(NotFound());
     }
     else
     {
         return(Ok(department.CollectionPoint));
     }
 }
Пример #29
0
 public IActionResult Index(User u)
 {
     if (ModelState.IsValid)
     {
         Models.Department d2 = b.getDepartmentDetails(dept);
         d2.RepId = u.UserId;
         context.SaveChanges();
         TempData["Alert1"] = "Department Representative Changed Successfully";
         return(RedirectToAction("Index"));
     }
     TempData["Alert2"] = "Please Try Again";
     return(RedirectToAction("Index"));
 }
 public ActionResult Create(Models.Department dep)
 {
     try
     {
         db.Departments.Add(dep);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }