Exemplo n.º 1
0
        public ServiceCategoryModel GetServiceCategoryInfo(int ID = 0)
        {
            ShomaRMEntities      db    = new ShomaRMEntities();
            ServiceCategoryModel model = new ServiceCategoryModel();


            var ServiceCategory = db.tbl_ServiceIssue.Where(p => p.ServiceIssueID == ID).FirstOrDefault();

            if (ServiceCategory != null)
            {
                model.ServiceIssueID = ServiceCategory.ServiceIssueID;
                model.ServiceIssue   = ServiceCategory.ServiceIssue;
            }

            return(model);
        }
Exemplo n.º 2
0
        public long SaveUpdateServiceCategory(ServiceCategoryModel model)
        {
            ShomaRMEntities db             = new ShomaRMEntities();
            var             userNameExists = db.tbl_ServiceIssue.Where(p => p.ServiceIssueID != model.ServiceIssueID && p.ServiceIssue == model.ServiceIssue).FirstOrDefault();

            if (userNameExists == null)
            {
                if (model.ServiceIssueID == 0)
                {
                    var ServiceData = new tbl_ServiceIssue()
                    {
                        ServiceIssue = model.ServiceIssue
                    };
                    db.tbl_ServiceIssue.Add(ServiceData);
                    db.SaveChanges();
                    model.ServiceIssueID = ServiceData.ServiceIssueID;
                }
                else
                {
                    var ServiceIssueData = db.tbl_ServiceIssue.Where(p => p.ServiceIssueID == model.ServiceIssueID).FirstOrDefault();
                    if (ServiceIssueData != null)
                    {
                        ServiceIssueData.ServiceIssue = model.ServiceIssue;
                        db.SaveChanges();
                    }
                    else
                    {
                        throw new Exception(model.ServiceIssue + " not exists in the system.");
                    }
                }

                return(model.ServiceIssueID);
            }
            else
            {
                throw new Exception(model.ServiceIssue + " already exists in the system.");
            }
        }