public void AssignEmployee(string employeeID, int errandID)
        {
            Errand dbEntry = context.Errands.FirstOrDefault(e => e.ErrandID == errandID);

            dbEntry.EmployeeId = employeeID;
            context.SaveChanges();
        }
        //Save or update errand
        public string SaveErrand(Errand errand)
        {
            if (errand.ErrandID == 0)
            {
                //Create new ID
                var sequenceObject = Sequence.First();
                int sequenceValue  = sequenceObject.CurrentValue;
                errand.RefNumber = "2020-45-" + sequenceValue;
                errand.StatusId  = "S_D";

                //Add errand to database
                context.Errands.Add(errand);

                //Update Sequence count
                sequenceValue++;
                sequenceObject.CurrentValue = sequenceValue;
                context.Sequences.Update(sequenceObject);
            }
            else
            {
                Errand dbEntry = context.Errands.FirstOrDefault(er => er.ErrandID == errand.ErrandID);
                if (dbEntry != null)
                {
                    //code to update here
                }
            }
            context.SaveChanges();
            return(errand.RefNumber);
        }
        //Add department to errand
        public void AssignDepartment(Department department, int errandID)
        {
            Errand dbEntry = context.Errands.FirstOrDefault(er => er.ErrandID == errandID);

            dbEntry.DepartmentId = department.DepartmentId;
            context.SaveChanges();
        }
        public void CloseCase(int errandID, string reason)
        {
            Errand dbEntry = context.Errands.FirstOrDefault(e => e.ErrandID == errandID);

            dbEntry.StatusId         = "S_B";
            dbEntry.InvestigatorInfo = string.Format("{0} {1}",
                                                     dbEntry.InvestigatorInfo, reason);
            context.SaveChanges();
        }
Example #5
0
        /// <summary>
        /// Method to add the errand object data to database if no similar ID exists.
        /// </summary>
        /// <param name="errand">object of errand to be added to to DB</param>
        /// <returns>Created errand's ref number to be shown in view.</returns>
        public string SaveErrand(Errand errand)
        {
            if (errand.ErrandId == 0)
            {
                context.Errands.Add(errand);
            }
            context.SaveChanges();

            return(errand.RefNumber);
        }
Example #6
0
        /// <summary>
        /// Methods to update information of an errand.
        /// </summary>
        /// <param name="errand"></param>
        /// <returns>The updated errand Id</returns>
        public int UpdateDepartment(Errand errand)
        {
            Errand dbEntry = context.Errands.FirstOrDefault(s => s.ErrandId == errand.ErrandId); //This Can be put in a different method which is called by each update method.

            if (dbEntry != null)
            {
                dbEntry.DepartmentId = errand.DepartmentId;
            }
            context.SaveChanges();
            return(errand.ErrandId);
        }
Example #7
0
        public int UpdateStatusId(Errand errand)
        {
            Errand dbEntry = context.Errands.FirstOrDefault(s => s.ErrandId == errand.ErrandId);

            if (dbEntry != null)
            {
                dbEntry.StatusId = errand.StatusId;
            }
            context.SaveChanges();
            return(errand.ErrandId);
        }
Example #8
0
        public int UpdateAction(Errand errand)
        {
            Errand dbEntry = context.Errands.FirstOrDefault(s => s.ErrandId == errand.ErrandId);

            if (dbEntry != null)
            {
                dbEntry.StatusId         = "S_B";
                dbEntry.InvestigatorInfo = errand.InvestigatorInfo;
                dbEntry.EmployeeId       = null;
            }
            context.SaveChanges();
            return(errand.ErrandId);
        }
        public void UpdateStatus(int errandID, string errandStatusID, string events, string information)
        {
            Errand dbEntry = context.Errands.FirstOrDefault(e => e.ErrandID == errandID);

            dbEntry.StatusId = errandStatusID;
            if (events != null)
            {
                dbEntry.InvestigatorAction += events;
            }
            if (information != null)
            {
                dbEntry.InvestigatorInfo += information;
            }
            context.SaveChanges();
        }
Example #10
0
        public int UpdateInvestigatorInfo(Errand errand)
        {
            Errand dbEntry = context.Errands.FirstOrDefault(s => s.ErrandId == errand.ErrandId);

            if (dbEntry != null)
            {
                if (dbEntry.InvestigatorInfo == null)
                {
                    dbEntry.InvestigatorInfo = errand.InvestigatorInfo;
                }
                else
                {
                    dbEntry.InvestigatorInfo += "\n" + errand.InvestigatorInfo;
                }
            }
            context.SaveChanges();
            return(errand.ErrandId);
        }
 public string SaveErrand(Errand errand)
 {
     throw new NotImplementedException();
 }