Exemple #1
0
        public ServiceIssueModel GetServiceIssueInfo(int ID = 0)
        {
            ShomaRMEntities   db    = new ShomaRMEntities();
            ServiceIssueModel model = new ServiceIssueModel();


            var Serissue = db.tbl_Issue.Where(p => p.IssueID == ID).FirstOrDefault();

            if (Serissue != null)
            {
                model.IssueID        = Serissue.IssueID;
                model.CausingIssueID = Serissue.CausingIssueID;
                model.ServiceIssueID = Serissue.ServiceIssueID;
                model.Issue          = Serissue.Issue;
            }

            return(model);
        }
Exemple #2
0
        public long SaveUpdateServiceIssue(ServiceIssueModel model)
        {
            ShomaRMEntities db             = new ShomaRMEntities();
            var             userNameExists = db.tbl_Issue.Where(p => p.IssueID != model.IssueID && p.Issue == model.Issue).FirstOrDefault();

            if (userNameExists == null)
            {
                if (model.IssueID == 0)
                {
                    var IssueData = new tbl_Issue()
                    {
                        CausingIssueID = model.CausingIssueID,
                        ServiceIssueID = model.ServiceIssueID,
                        Issue          = model.Issue,
                    };
                    db.tbl_Issue.Add(IssueData);
                    db.SaveChanges();
                    model.IssueID = IssueData.IssueID;
                }
                else
                {
                    var SIssueData = db.tbl_Issue.Where(p => p.IssueID == model.IssueID).FirstOrDefault();
                    if (SIssueData != null)
                    {
                        SIssueData.CausingIssueID = model.CausingIssueID;
                        SIssueData.ServiceIssueID = model.ServiceIssueID;
                        SIssueData.Issue          = model.Issue;
                        db.SaveChanges();
                    }
                    else
                    {
                        throw new Exception(model.Issue + " not exists in the system.");
                    }
                }

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