示例#1
0
        public async Task <SingleResponse <Docs> > UpdateDocsAsync(Docs docs, Type type)
        {
            var response = new SingleResponse <Docs>();

            var EntityTypeId = DbContext.GetEntityTypeIdByEntityTypeName(type).Result;

            docs.EntityTypeId = EntityTypeId;


            var entity = GetDocsAsync((int)docs.EntityTypeId, (int)docs.EntityId, (int)docs.DocumentTypeId);

            if (entity.Result.Model != null)
            {
                entity.Result.Model.DocumentPath     = docs.DocumentPath;
                entity.Result.Model.IsDocumentSigned = docs.IsDocumentSigned;
                entity.Result.Model.LanguageId       = docs.LanguageId;

                DbContext.Update(entity.Result.Model, UserInfo);

                await DbContext.SaveChangesAsync();
            }


            response.SetMessageSucssesPost(nameof(UpdateDocsAsync), docs.EntityId ?? 0);

            response.Model = docs;

            return(response);
        }
示例#2
0
        public async Task <SingleResponse <PhoneMail> > UpdatePhoneMailAsync(PhoneMail phoneMail, Type type)
        {
            var response = new SingleResponse <PhoneMail>();


            var EntityTypeId = DbContext.GetEntityTypeIdByEntityTypeName(type).Result;

            phoneMail.EntityTypeId = EntityTypeId;


            var entity = GetPhoneMailAsync((int)phoneMail.EntityTypeId, (int)phoneMail.EntityId);

            if (entity.Result.Model != null)
            {
                entity.Result.Model.Email       = phoneMail.Email;
                entity.Result.Model.PhoneNumber = phoneMail.PhoneNumber;
                entity.Result.Model.PhoneTypeId = phoneMail.PhoneTypeId;

                DbContext.Update(entity.Result.Model, UserInfo);

                await DbContext.SaveChangesAsync();
            }
            response.SetMessageSucssesPost(nameof(CreatePhoneMailAsync), phoneMail.EntityId ?? 0);

            response.Model = phoneMail;

            return(response);
        }
示例#3
0
        public async Task <SingleResponse <Docs> > CreateDocsAsync(Docs docs, Type type, string fileName, FileRequest file, int documentType)
        {
            if (fileName == null)
            {
                fileName = type.ToString();
            }
            if (file != null)
            {
                //אם יש כבר תמונה אז יש צורך לעדכן את מה שיש
                var query = DbContext.GetDocsAsync(new Docs {
                    EntityTypeId = (int)docs.EntityTypeId, EntityId = (int)docs.EntityId, DocumentTypeId = documentType
                });

                var docExist = await query;
                docs.DocumentTypeId = documentType;
                if (docExist != null)
                {
                    //למחוק את הכתובת הקודמת מהבלוב
                    //  blobStorageService.DeleteBlobData(docExist.Result.Model.DocumentPath);

                    docs.DocumentPath = blobStorageService.UploadFileToBlob(fileName, file);

                    return(await UpdateDocsAsync(docs, type));
                }
                else //if (file != null)
                {
                    //אם אין תמונה יוצרים חדש
                    if (!string.IsNullOrEmpty(file.ContentType) || !string.IsNullOrEmpty(file.ContentType))
                    {
                        var response = new SingleResponse <Docs>();

                        docs.DocumentPath = blobStorageService.UploadFileToBlob(fileName, file);

                        var EntityTypeId = DbContext.GetEntityTypeIdByEntityTypeName(type).Result;

                        docs.EntityTypeId = EntityTypeId;

                        DbContext.Add(docs, UserInfo);

                        await DbContext.SaveChangesAsync();

                        response.SetMessageSucssesPost(nameof(CreateDocsAsync), docs.EntityId ?? 0);

                        response.Model = docs;

                        return(response);
                    }
                    else
                    {
                        return(new SingleResponse <Docs>());
                    }
                }
            }
            else
            {
                return(new SingleResponse <Docs>());
            }
        }
示例#4
0
        public async Task <SingleResponse <EmployeeProffesionType> > CreateEmployeeProffesionTypeAsync(EmployeeProffesionType proffesionType, Type type)
        {
            var response = new SingleResponse <EmployeeProffesionType>();

            DbContext.Add(proffesionType, UserInfo);

            await DbContext.SaveChangesAsync();

            response.SetMessageSucssesPost(nameof(CreateEmployeeProffesionTypeAsync), proffesionType.EmployeeAuthorizationId);

            response.Model = proffesionType;

            return(response);
        }
示例#5
0
        // POST
        public async Task <SingleResponse <Organization> > CreateOrganizationAsync(Organization organization)
        {
            var response = new SingleResponse <Organization>();

            // Add entity to repository
            DbContext.Add(organization, UserInfo);
            // Save entity in database
            await DbContext.SaveChangesAsync();

            response.SetMessageSucssesPost(nameof(CreateOrganizationAsync), organization.OrganizationId ?? 0);
            // Set the entity to response model
            response.Model = organization;

            return(response);
        }
示例#6
0
        // POST
        public async Task <SingleResponse <SiteEmployee> > CreateSiteEmployeeAsync(SiteEmployee siteEmployee)
        {
            var response = new SingleResponse <SiteEmployee>();

            // Add entity to repository
            DbContext.Add(siteEmployee, UserInfo);
            // Save entity in database
            await DbContext.SaveChangesAsync();


            response.SetMessageSucssesPost(nameof(SiteEmployee), siteEmployee.SiteEmployeeId);
            // Set the entity to response model
            response.Model = siteEmployee;

            return(response);
        }
示例#7
0
        public async Task <SingleResponse <PhoneMail> > CreatePhoneMailAsync(PhoneMail phoneMail, Type type)
        {
            var response = new SingleResponse <PhoneMail>();

            var EntityTypeId = DbContext.GetEntityTypeIdByEntityTypeName(type).Result;

            phoneMail.EntityTypeId = EntityTypeId;

            DbContext.Add(phoneMail, UserInfo);

            await DbContext.SaveChangesAsync();

            response.SetMessageSucssesPost(nameof(CreatePhoneMailAsync), phoneMail.EntityId ?? 0);

            response.Model = phoneMail;

            return(response);
        }
示例#8
0
        public async Task <SingleResponse <EmployeeProffesionType> > UpdateProffesionTypeAsync(EmployeeProffesionType proffesionType, Type type)
        {
            var response = new SingleResponse <EmployeeProffesionType>();


            var entity = DbContext.EmployeeProffesionType.FirstOrDefault(item => item.EmployeeId == proffesionType.EmployeeId && item.ProffesionTypeId == proffesionType.ProffesionTypeId);

            if (entity != null)
            {
                entity.ProffesionTypeId = proffesionType.ProffesionTypeId;

                DbContext.Update(entity, UserInfo);

                await DbContext.SaveChangesAsync();
            }
            response.SetMessageSucssesPost(nameof(CreatePhoneMailAsync), proffesionType.EmployeeAuthorizationId);

            response.Model = proffesionType;

            return(response);
        }