Example #1
0
 public IssueFeedbackStruct(IssueFeedback feedback)
 {
     this.description = feedback.description;
     this.accessicon  = (feedback.accesstype == IssueFeedback.ACCESSTYPE_PUBLIC) ? "" : Images.PRIVATE();
     this.name        = feedback.createdname;
     this.date        = DateUtils.ConvertToDateString(feedback.createddate);
     this.time        = DateUtils.ConvertToTimeString(feedback.createddate);
 }
Example #2
0
 public IssueTransitionStruct(IssueTransition transition)
 {
     this.fromstatus = Issue.StatusAsString(transition.fromstatus);
     this.tostatus   = Issue.StatusAsString(transition.tostatus);
     this.statusicon = Images.StatusAsImage(transition.tostatus);
     this.name       = transition.createdname;
     this.date       = DateUtils.ConvertToDateString(transition.createddate);
     this.time       = DateUtils.ConvertToTimeString(transition.createddate);
 }
Example #3
0
 public UIOffer_CRU(Offer model)
 {
     this.id            = model.id;
     this.customerid    = model.customerid;
     this.category      = model.category;
     this.headline      = model.headline;
     this.message       = model.message;
     this.author        = model.author;
     this.sent          = DateUtils.ConvertToDateTimeString(model.sent);
     this.showfromdate  = DateUtils.ConvertToDateString(model.showfrom);
     this.showfromtime  = DateUtils.ConvertToTimeString(model.showfrom);
     this.showuntildate = DateUtils.ConvertToDateString(model.showuntil);
     this.showuntiltime = DateUtils.ConvertToTimeString(model.showuntil);
 }
Example #4
0
 public IssueProblemStruct(Issue issue, Customer customer)
 {
     this.issueid         = issue.id;
     this.name            = issue.name;
     this.assignedid      = issue.assignedid;
     this.startdatestring = DateUtils.ConvertToDateString(issue.startdate);
     this.starttimestring = DateUtils.ConvertToTimeString(issue.startdate);
     this.enddatestring   = DateUtils.ConvertToDateString(issue.enddate);
     this.endtimestring   = DateUtils.ConvertToTimeString(issue.enddate);
     this.issueclassid    = issue.issueclassid;
     this.prio            = issue.prio;
     this.responsible     = issue.responsible;
     this.areatype        = issue.areatype;
     this.description     = issue.description;
     this.customername    = (customer == null) ? "--" : customer.name;
 }
Example #5
0
        public static bool TrySecure(Account requester, DataContext context, Account dbentity, string PIN)
        {
            long now = DateUtils.TimeStamp;

            if (dbentity.IsLocked(now))
            {
                throw new ServerConflictException("Det här kontot är låst till " + DateUtils.ConvertToTimeString(dbentity.lockeduntil));
            }
            dbentity.Validate();
            context.Entry(dbentity).State = System.Data.Entity.EntityState.Modified;
            if (dbentity.PIN != PIN || dbentity.PINvaliduntil < now)
            {
                dbentity.RegisterFailedAttempt(now);
                return(false);
            }
            dbentity.SetSuccessfulLogin(now);
            dbentity.active = Account.ACTIVE;
            return(true);
        }
Example #6
0
        public static void TryCreate(Account requester, DataContext context, Issue issue)
        {
            if (requester.IsAtMostCustomer() && issue.customerid != requester.customerid)
            {
                throw new ServerAuthorizeException("Du har inte behörighet att skapa ärende");
            }
            issue.Validate();

            Issue busy = context.Issues.CollidesWith(issue);

            if (busy != null)
            {
                string t0 = DateUtils.ConvertToTimeString(busy.startdate);
                string t1 = DateUtils.ConvertToTimeString(busy.enddate);
                throw new ServerConflictException("Tilldelad redan bokad på ärende " + busy.id + " (" + t0 + "-" + t1 + ")");
            }

            context.Issues.Add(issue);
        }
        public static Account TryValidate(Account requester, DataContext context, string password)
        {
            long now = DateUtils.TimeStamp;

            password = StringUtils.Trim(password);
            if (String.IsNullOrWhiteSpace(password))
            {
                throw new ServerValidateException("Felaktigt lösenord");
            }

            if (requester.IsInactive())
            {
                throw new ServerConflictException("Kontot inaktiverat");
            }

            if (requester.IsLocked(now))
            {
                throw new ServerConflictException("Det här kontot är låst till " + DateUtils.ConvertToTimeString(requester.lockeduntil));
            }

            if (requester.IsAtMostCustomer())
            {
                Customer customer = context.Customers.Find(requester.customerid);
                if (customer == null || customer.id == Customer.CUSTOMER_ANY || customer.IsInactive())
                {
                    throw new ServerConflictException("Din förening tillåter inte inloggning");
                }
            }

            context.Entry(requester).State = System.Data.Entity.EntityState.Modified;
            if (!CryptoUtils.VerifyMD5Hash(password, requester.password))
            {
                requester.RegisterFailedAttempt(now);
                return(null);
            }
            requester.SetSuccessfulLogin(now);
            return(requester);
        }
Example #8
0
        public static Issue TryUpdate(Account requester, DataContext context, Issue dbentity)
        {
            if (requester.IsAtMostCustomer() && dbentity.customerid != requester.customerid)
            {
                throw new ServerAuthorizeException("Du har inte behörighet att uppdatera ärende");
            }
            if (requester.IsResident() && dbentity.areatype == Issue.AREATYPE_APARTMENT && requester.id != dbentity.residentid)
            {
                throw new ServerAuthorizeException("Du har inte behörighet att uppdatera ärende");
            }
            dbentity.Validate();

            Issue busy = context.Issues.CollidesWith(dbentity);

            if (busy != null)
            {
                string t0 = DateUtils.ConvertToTimeString(busy.startdate);
                string t1 = DateUtils.ConvertToTimeString(busy.enddate);
                throw new ServerConflictException("Tilldelad redan bokad på ärende " + busy.id + " (" + t0 + "-" + t1 + ")");
            }

            context.Entry(dbentity).State = System.Data.Entity.EntityState.Modified;
            return(dbentity);
        }